import Types from '../actionTypes';

let initState = {
  pageCount: 1,
  supplierOrderList: [],
  current: 1,
  supplierOrderDetials: {}, // 供应商订单详情
  logisticsTemplate: [], // 物流模板
  address: {} // 收货地址
};

export default (state = initState, action) => {
  const newState = JSON.parse(JSON.stringify(state));
  switch (action.type) {
    case Types.SUPPLIER_ORDER_LIST:
      newState.pageCount = action.res.pageCount;
      newState.supplierOrderList = action.res.order;
      newState.current = Number(action.res.page);
      return newState;
    case Types.GET_SUPPLIER_ORDER_DETAILS:
      newState.supplierOrderDetials = action.data;
      return newState;
    case Types.LOGISTICS_TEMPLATE:
      newState.logisticsTemplate = action.data;
      return newState;
    case Types.GET_ADDRESS:
      newState.address = action.data;
      return newState;
    default:
      console.log('Types no match in supplierBefore.js ....');
  }
  return state;
}
